package com.doit.dict.page;/**
 * Created by hunter.coder 涛哥
 * 2019/4/9 9:34
 * 交流qq:657270652
 * Version: 1.0
 * 更多学习资料：https://blog.csdn.net/coderblack/
 * Description:
 **/

import java.io.*;
import java.util.ArrayList;
import java.util.Random;

/**
 * @Author hunter.coder
 * @Date 2019/4/9 9:34
 * @Version 1.0
 * @Description TODO
 **/
public class Items {

    public static void main(String[] args) throws Exception {
        BufferedReader br2 = new BufferedReader(new FileReader("D:\\dev-workspace\\eagle\\datagenerator\\dicts\\cat2.txt"));
        String l = null;
        ArrayList<String> catIds = new ArrayList<>();
        while((l=br2.readLine())!=null){
            String[] split = l.split(",");
            catIds.add(split[0]);
        }

        Random rd = new Random();

        BufferedReader br = new BufferedReader(new FileReader("D:\\dev-workspace\\eagle\\datagenerator\\dicts\\items.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\dev-workspace\\eagle\\datagenerator\\dicts\\item_details.txt"));
        String line = null;
        while((line=br.readLine())!=null){
            String[] split = line.split("\001");
            String itemid = split[0].substring(split[0].lastIndexOf("/")+1);
            bw.write(itemid+","+catIds.get(rd.nextInt(catIds.size()))+","+split[1]+","+(10d+rd.nextInt(100))/10);
            bw.newLine();
        }
        bw.close();
        br.close();

    }
}
